﻿using System.ServiceProcess;
using BloggerAutoPosterService.Engine.Core;
using BloggerAutoPosterService.Engine.Net;

namespace BloggerAutoPosterService
{
    public partial class Main : ServiceBase
    {
        readonly ScheduledJobRunner _scheduledJobRunner;

        public Main()
        {
            InitializeComponent();
            _scheduledJobRunner = new ScheduledJobRunner(new RedirectFinder(), new ServiceConfig(useApplicationPath: false));
        }

        protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus)
        {
            OnStop();
            return base.OnPowerEvent(powerStatus);
        }

        protected override void OnShutdown()
        {
            OnStop();
            base.OnShutdown();
        }

        protected override void OnStart(string[] args)
        {
            _scheduledJobRunner.OnStart();
        }

        protected override void OnStop()
        {
            _scheduledJobRunner.OnStop();
        }
    }
}
